home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 3
/
ct-rom iiib.zip
/
ct-rom iiib
/
WINDOWS
/
UTILITY
/
DESKTOP
/
W_ONE49
/
SPLIT.CP_
/
SPLIT.CP
Wrap
Text File
|
1994-04-27
|
3KB
|
90 lines
#include "split.h"
/******************************************************************\
* *
* w w oooo *
* w w iii n n o o n n eeee *
* w w i nn n o o nn n e *
* w w w i n n n o o n n n eee *
* w w w w i n nn o o n nn e *
* w w iii n n oooo n n eeee *
* *
* C o m m a n d L a n g u a g e I n t e r p r e t e r *
* *
* *
* Written by Lucien Cinc *
* Copyright (c) 1992, 1993 *
* *
\******************************************************************/
int split(char *path, long offset);
int main(void)
{
int offset;
char *sp;
sp = args(); // parse command line switches
while(*sp)
switch(*sp++) {
case 'v' : // show version information
printf("%cVersion %c%d.%01d\n", WHITE, YELLOW, VERSION / 10, VERSION % 10);
return 0;
default: // invalid switch
perror("Invalid switch");
return 1;
}
if (argnstr()) { // no string arguments
perror("Invalid argument");
return 1;
}
if (argc() != 2) {
perror("To many or few arguments");
return 1;
}
return split(argabs(1), atol(argv(2))); // split the file
}
int split(char *path, long offset)
{
long num;
char dst[MAXPATH], src[MAXPATH];
strcpy(dst, path);
strcpy(src, path);
if ((num = filesize(src)) == -1) {
perror("Invalid path or file name");
return 1;
}
limit(num); // status bar limit
if (offset < 0 || offset > num) {
perror("Out of range");
empty();
return 1;
}
strcpy(strrchr(dst, '.'), ".1"); // first half
printf("%c%s %c%9ld%c\n", GREEN, unixpath(padfilename(dst)), YELLOW, offset, LIGHTGRAY);
if (filencpy(dst, src, offset, 0, O_CREATNEW, INC_BYTE) == -1) {
empty();
return 1;
}
strcpy(strrchr(dst, '.'), ".2"); // second half
printf("%c%s %c%9ld%c\n", GREEN, unixpath(padfilename(dst)), YELLOW, num - offset, LIGHTGRAY);
if (filencpy(dst, src, -1, offset, O_CREATNEW, INC_BYTE) == -1) {
empty();
return 1;
}
empty(); // finished with status bar
return 0;
}